package com.atguigu.jxc.service.impl;

import com.atguigu.jxc.dao.SuppliersDao;
import com.atguigu.jxc.entity.Supplier;
import com.atguigu.jxc.service.SuppliersService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service
public class SuppliersServiceImpl implements SuppliersService {

    @Autowired
    private SuppliersDao suppliersDao;

    @Override
    public PageInfo<Supplier> queryPage(Integer page, Integer rows, String supplierName) {
        PageHelper.startPage(page, rows);
        List<Supplier> supplier = suppliersDao.queryPage(supplierName);
        if (CollectionUtils.isEmpty(supplier)) {
            return null;
        }
        PageInfo<Supplier> result = new PageInfo<>(supplier);
        return result;
    }
}
